package com.css.fxfzypg.modules.baseData.service.impl;

import com.css.fxfzypg.modules.baseData.entity.*;
import com.css.fxfzypg.modules.baseData.repository.BasicDataRepository;
import com.css.fxfzypg.modules.baseData.service.BasicDataService;
import com.css.fxfzypg.modules.preAssessResult.entity.Vulnerability;
import com.css.fxfzypg.util.UUIDGenerator;
import org.springframework.stereotype.Service;
import org.springframework.test.annotation.Rollback;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author Dbj
 * @date 2022年10月16日  10:21
 */
@Service
public class BasicDataServiceImpl implements BasicDataService {

    @Resource
    private BasicDataRepository basicDataRepository;
    @Override
    public List<TaskPbe> getAllPbeByTaskId(String taskId) {
        List<TaskPbe> taskPbeList = basicDataRepository.getAllPbeByTaskId(taskId);
        return taskPbeList;
    }

    @Override
    @Transactional(rollbackFor=Exception.class)
    public void save(CenterResult centerResult) {
        centerResult.setUuid(UUIDGenerator.getUUID());
        basicDataRepository.save(centerResult);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void updateTaskPbe(TaskPbe pbe) {
        basicDataRepository.updateTaskPbe(pbe);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void deleteCenterResultByTaskId(String taskId) {
        basicDataRepository.deleteCenterResultByTaskId(taskId);
    }

    @Override
    public List<CenterResult> getCenterResult(String taskId) {
        return basicDataRepository.getCenterResult(taskId);
    }

    @Override
    public void insertTaskPbe(TaskPbe pbe) {
        basicDataRepository.insertTaskPbe(pbe);
    }

    @Override
    public void deleteSettingSeismicPbeByTaskId(String taskId) {
         basicDataRepository.deleteSettingSeismicPbeByTaskId(taskId);
    }

    @Override
    public void deleteSettingSeismicPbeEconomicByTaskId(String taskId) {
        basicDataRepository.deleteSettingSeismicPbeEconomicByTaskId(taskId);
    }

    @Override
    public void insertTaskPbeEconomic(TaskPbeEconomic taskPbeEconomic) {
        basicDataRepository.insertTaskPbeEconomic(taskPbeEconomic);
    }

    @Override
    public int getPbeByTaskId(String taskId) {
        return basicDataRepository.getPbeByTaskId(taskId);
    }

    @Override
    public int getEconomicByTaskId(String taskId) {
        return basicDataRepository.getEconomicByTaskId(taskId);
    }

    @Override
    public List<CenterSumResult> getCenterSumResult(String taskId) {
        return basicDataRepository.getCenterSumResult(taskId);
    }

    @Override
    public int getPbeInjuriesByTaskId(String taskId) {
        return basicDataRepository.getPbeInjuriesByTaskId(taskId);
    }

    @Override
    public int getPbeLossesByTaskId(String taskId) {
        return basicDataRepository.getPbeLossesByTaskId(taskId);
    }
}
